package com.iotest;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author: huhx
 * @Date: 2017-11-10 下午 3:45
 */
public class CopyBytes {
    public static void main(String[] args) throws IOException {
        FileInputStream in = null;
        FileOutputStream out = null;

        try {
            // 这种读写的方式不会产生乱码，乱码的产生是编码格式不一致导致的。
            in = new FileInputStream("huhx-test/file/huhx.txt");
            out = new FileOutputStream("huhx-test/file/linux.txt");
            int c;

            while ((c = in.read()) != -1) {
                out.write(c);
            }
        } finally {
            if (in == null) {
                in.close();
            }
            if (out == null) {
                out.close();
            }
        }
    }
}
